<?php 
$mon = $this->common_model->getdata('subjects',array('publish'=>1,'parentid !='=>0),array('id','title'));
$userid = $this->session->userdata('id');
$alias = preg_replace("/(.html)/",'', $this->security->xss_clean($this->uri->segment(2,0)));
$idusser = substr($alias,17);
?>
<p class="intro_email">Để gửi email cho gia sư xin phụ huynh hoặc học sinh vui lòng nhập  theo mẫu Form bên dưới</p>
		<div class="form_sent">
			<textarea <?php if($userid == $idusser && $userid != ''){echo 'disabled';} ?> required="required" id="noidung" class="arena noidung text_box1" name="content"></textarea>
			<!-- /.arena -->
			<p class="title1">Môn học</p>
			<input <?php if($userid == $idusser && $userid != ''){echo 'disabled';} ?> required="required" id="subjects" type="text" class="text_box1 subjects" name="subjects" placeholder="VD : Vật lí" />
			<?php if(!$userid){ ?>
            <div class="inline_input">
				<p class="title1">Họ và tên</p>
				<input type="text" class="text_box1 name style_50" required="required" id="name" name="name" value="<?php if(!empty($_POST['lastname'])){echo $_POST['lastname'];}?>" />
			</div>
            <p class="title1">Điện thoại</p>
			<input type="text" class="input text_box1 phone style_100" required="required" id="phone" name="phone" />
			<p class="title1">Emails</p>
			<input type="text" class="input text_box1 email style_100" required="required" id="email" name="email" value="<?php if(!empty($_POST['email'])){echo $_POST['email'];}?>" />
            <?php echo form_error('email');?>
			<p class="title1">Nhập lại Emails</p>
			<input type="text" class="input text_box1 repeatemail style_100" required="required" id="repeatemail" name="repeatemail" value="<?php if(!empty($_POST['repeatemail'])){echo $_POST['repeatemail'];}?>" />
            <?php echo form_error('repeatemail');?>
            <?php } ?>
   </div>
            <div class="node">
                <?php if(!empty($thongbao1)){echo $thongbao1;}?>
        </div>
<a href="javascript://" class="btn_details sent_mails" title="Gửi"><i class="icon-envelope"></i>&nbsp;&nbsp;Gửi email</a>        
<script>
$(document).ready(function() {
var availableTags = [<?php if(!empty($mon)){
    $i=0;
    $n=count($mon);
    foreach($mon as $mon){
        if($i==$n){
            echo '"'.$mon->title.'"';
        }else{
            echo '"'.$mon->title.'",';
        }
        
        $i++;
    }
}?>
  
];
$( ".subjects" ).autocomplete({
  source: availableTags,disabled: false,autoFocus:true,widget:true,delay:0
});
});
</script>
<script>
$(document).ready(function(){
    $('.sent_mails').click(function(){
       var des_email = $('#noidung').val();
       var name = $('#name').val();
		var email = $('#email').val();
       var phone=$('#phone').val();
       var repeatemail = $('#repeatemail').val();
       var subjects = $('#subjects').val();
       var url = window.location.pathname;
       $('.form_sent').append('<div class="loading"><i class="icon-spinner icon-spin icon-large"></i> Đang tải dữ liệu vui lòng đợi...</div>')
             $.ajax({
                      type: "POST",
                      url: '<?php echo base_url(); ?>ajax/guiemail',
                      data: {
                        des_email : des_email,
                        name : name,
                        email : email,
                        phone: phone,
                        repeatemail : repeatemail,
                        url: url,
                        subjects:subjects
                        
                        },
                      success: success
                    });
    });
    function success(data,status){
            $('.loading').remove();
            $('.tong').html(data);
           };
});
</script>          